/**
 * @USER: Administrator
 * @DATE: 2024/9/16 下午11:18
 * @VERSION: 1.0.0
 */
public class LC908 {
    public static void main(String[] args) {

    }



    public int smallestRangeI(int[] nums, int k) {
        int min = nums[0];
        int max = nums[0];

        for (int num : nums) {
            if (num < min) {
                min = num;
            }
            if (num > max) {
                max = num;
            }
        }

        return Math.max(0,max - min-2*k);

    }

}
